
# CMakeList.txt:FYT2021 的 CMake 项目，在此处包括源代码并定义项目特定的逻辑。

cmake_minimum_required (VERSION 3.5)

project(FYT2021)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${CMAKE_SYSTEM_NAME}")

if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    set(OpenCV_DIR D:/opencv/build)
    set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
    set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)
endif()

find_package(OpenCV REQUIRED)

include_directories(${PROJECT_SOURCE_DIR}/Camera/Include)

set(SRC
    "FYT2021.cpp"
    "SerialPort/SerialPort.cpp"
    "SerialPort/Protocol.cpp"
    "Camera/FightingMVCapture.cpp"
    "Camera/FightingDahengCapture.cpp"
    "Camera/FightingVideoCapture.cpp"
    "Camera/FightingUSBCapture.cpp"
    "Armor/ArmorDetector.cpp"
    "Rune/RuneDetector.cpp"
    "Config/CameraParam.cpp"
    "Config/ArmorParam.cpp"
    "Config/RuneParam.cpp"
)

add_executable (FYT2021 ${SRC})

if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    target_link_libraries( FYT2021 ${OpenCV_LIBS})
    target_link_libraries( FYT2021 "${PROJECT_SOURCE_DIR}/Camera/lib/x64/MVCAMSDK_X64.lib" )
    target_link_libraries( FYT2021 "${PROJECT_SOURCE_DIR}/Camera/lib/x64/GxIAPI.lib" )
    target_link_libraries( FYT2021 "${PROJECT_SOURCE_DIR}/Camera/lib/x64/DxImageProc.lib" )
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
    target_link_libraries( FYT2021 ${OpenCV_LIBS} -lpthread)
    target_link_libraries( FYT2021 "libMVSDK.so" )  
    target_link_libraries( FYT2021 "libgxiapi.so" )  
endif()

file(COPY "${PROJECT_SOURCE_DIR}/Config/CameraParam.yml" DESTINATION ${EXECUTABLE_OUTPUT_PATH}/)
file(COPY "${PROJECT_SOURCE_DIR}/Config/ArmorParam.yml" DESTINATION ${EXECUTABLE_OUTPUT_PATH}/)
file(COPY "${PROJECT_SOURCE_DIR}/Config/RuneParam.yml" DESTINATION ${EXECUTABLE_OUTPUT_PATH}/)
file(COPY "${PROJECT_SOURCE_DIR}/Config/svm.xml" DESTINATION ${EXECUTABLE_OUTPUT_PATH}/)
file(COPY "${PROJECT_SOURCE_DIR}/Template/" DESTINATION ${EXECUTABLE_OUTPUT_PATH}/)
file(COPY "${PROJECT_SOURCE_DIR}/Config/MV-SUA134GC-Group0.config" DESTINATION ${EXECUTABLE_OUTPUT_PATH}/Camera/Configs/)